<?php 
	session_start();
	if (!isset($_SESSION['login'])) Header("Location:../../index.php");
	require_once('../controllers/UIs/UIAplicacion.php');
	require_once('../controllers/UIs/UIEmpresa.php');
	require_once('../controllers/UIs/UIInstrumento.php');	
?>
<!--?xml version="1.0"?!-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="cs" lang="cs">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-language" content="cs" />
    <meta name="robots" content="all,follow" />

    <meta name="author" content="All: ... [Nazev webu - www.url.cz]; e-mail: info@url.cz" />
    <meta name="copyright" content="Design/Code: Vit Dlouhy [Nuvio - www.nuvio.cz]; e-mail: vit.dlouhy@nuvio.cz" />
    
    <title>ASODECO encuestas</title>
    <meta name="description" content="..." />
    <meta name="keywords" content="..." />
    
    <link rel="index" href="./" title="Home" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="../../resources/css/main.css" />
    <link rel="stylesheet" media="print" type="text/css" href="../../resources/css/print.css" />
    <link rel="stylesheet" media="aural" type="text/css" href="../../resources/css/aural.css" />
    
	<script language="javascript">
    
		var nav = (document.layers) ? true : false
		
		function changeOn(Boton){
			if (!nav && Boton) Boton.src="../../resources/design/saveOn.gif" //modificamos el color
		}
	
		function changeClick(Boton){
			if (!nav && Boton) Boton.src="../../resources/design/saveOn.gif" //modificamos el color
		}
		
		function changeOff(Boton){
			if (!nav && Boton) Boton.src="../../resources/design/save.gif" //modificamos el color
		}


		// funciones equivalentes al trim
		function ltrim(s) {
		   return s.replace(/^\s+/, "");
		}
		
		function rtrim(s) {
		   return s.replace(/\s+$/, "");
		}
		
		function trim(s) {
		   return rtrim(ltrim(s));
		}
		
		// función de validación de los campos de texto
		function checkFields(frm)
		{
			nombre = new String();
			desc = new String();
			
		nombre = frm.nombre.value;
		desc = frm.desc.value;
			
			if ((trim(nombre)).length == 0 || 
				(trim(desc)).length == 0){ 
				alert("Debe introducir los datos correspondientes");
				return false;
			}
			
			return true;
		}
    </script>
	
	
	<!--Calendario-->
  <script language="JavaScript">

   var nInput;

   function calen(n){
    var oWnd;
    nInput = n;
    oWnd = open("Calendario.htm", "fechas", "location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no,width=180,height=200");
    oWnd.focus();
   }

   function fillDateField(){
    with (document.frm)
     if (nInput == 1)
      fechaInicial.value = dateResult.value;
     else
      fechaFinal.value = dateResult.value;
   }

  </script>	
  
<!-- Desabilita el boton derecho del mouse -->
<script language="JavaScript">
   var message = "";

   function clickIE(){
    if (document.all){
     (message);
     return false;
    }
   }

   function clickNS(e){
    if (document.layers || (document.getElementById && !document.all)){
     if (e.which == 2 || e.which == 3){
      (message);
      return false;
     }
    }
   }

   if (document.layers){
    document.captureEvents(Event.MOUSEDOWN);
    document.onmousedown = clickNS;
   } else {
    document.onmouseup = clickNS;
    document.oncontextmenu = clickIE;
   }
   document.oncontextmenu = new Function("return false")
  </script>
	
	
	
</head>

<body id="www-url-cz">

<!-- Main -->
<div id="main" class="box">

    <!-- Header -->
    <div id="header">

        <!-- Logotyp -->
        <h1 id="logo"><!a href="./" title="Crystal X [Go to homepage]">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<strong>ASODECO </strong><span></span><!/a></h1>
        <hr class="noscreen" />          

        <!-- Quick links -->
        <div class="noscreen noprint">
            <p><em>Quick links: <a href="#content">content</a>, <a href="#tabs">navigation</a>, <a href="#search">search</a>.</em></p>
            <hr />
        </div>

    </div> <!-- /header -->

     <!-- Main menu (tabs) -->
     <div id="tabs" class="noprint">

            <h3 class="noscreen">Navigation</h3>
            <ul class="box">
                <li><a href="../../index.php">Inicio<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="empresas.php">Empresas<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="instrumentos.php">Instrumentos<span class="tab-l"></span><span class="tab-r"></span></a></li> 
                <li id="active"><a href="aplicaciones.php">Aplicaciones<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="resultados.php">Resultados<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="usuarios.php">Usuarios<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="config.php">Configuración<span class="tab-l"></span><span class="tab-r"></span></a></li>
                <li><a href="sync.php">Sincronizar<span class="tab-l"></span><span class="tab-r"></span></a></li>
            </ul>

        <hr class="noscreen" />
     </div> <!-- /tabs -->

    <!-- Page (2 columns) -->
    <div id="page" class="box">
    <div id="page-in" class="box">



        <!-- Content -->
        <div id="content">

            <!-- Article -->
            <div class="article">
                <h2><span>Agregar Aplicación</span></h2>
                <br />
                <p class="info noprint">
                    <span class="cat"><b>Por favor complete los siguientes campos obligatorios (*): </b></span><span class="noscreen">,</span>&nbsp;&nbsp;&nbsp;
                </p>
             <form method="post" action="addaplicaciones_ui.php" id="frminstrumento" OnSubmit="return checkFields(this)" name="frm">
				<table width="100%">
                	<tr>            
                        <td width="50%"><label>(*) Nombre del Instrumento</label></td>
                        <td >
                            <SELECT NAME="id_instrumento" > 
                        	<?php 
								$instrumentos =  obtenerInstrumentoOrdenados();
								if (!empty($instrumentos)) {
									$numero = count($instrumentos);
									for($i=0; $i<$numero; $i++) {
							?>
                               <OPTION value="<?php echo $instrumentos[$i]->id?>"><?php echo $instrumentos[$i]->nombre?></OPTION> 
                             <?php }
								}?>
                            </SELECT>     
                        </td>                        
                    </tr>
                    <tr>
                        <td width="50%"><label>(*) Nombre de la empresa</label></td>
                        <td >
                            <SELECT NAME="id_empresa" > 
                        	<?php 
								$empresas = obtenerEmpT();
								if (!empty($empresas)) {
									$numero = count($empresas);
									for($i=0; $i<$numero; $i++) {
							?>
                               <OPTION value="<?php echo $empresas[$i]->id?>"><?php echo $empresas[$i]->razon_social?></OPTION> 
                             <?php }
								}?>
                            </SELECT>     
                        </td>                        
                    </tr>
                	<tr>            
                        <td width="50%"><label>(*) Cantidad de invitaciones</label></td>
                        <td ><input name="cantidad" type="text" maxlength="30" /> <script language="javascript">
							// sample of date calculations:
							// - set selected day to 3 days from now
							var d_selected = new Date();
							//d_selected.setDate(d_selected.getDate() + 3);
							var s_selected = f_tcalGenerDate(d_selected);
							
							// - set today as yesterday
							var d_yesterday = new Date();
							d_yesterday.setDate(d_yesterday.getDate() - 1);
							var s_yesterday = f_tcalGenerDate(d_yesterday);

							new tcal ({
								// form name
								'formname': 'insertarequiv',
								// input name
								'controlname': 'fecha1',
								'selected' : s_selected,
								'today' : s_yesterday
							});
							</script></td>
                    </tr>
                	<tr>            
                        <td width="50%"><label>(*) Fecha de inicio </label></td>
						<td>
							<input type="text" name="fechaInicial" maxlength="30">
							<input type="button" value="..." onclick="calen(1)">
						</td>
                    </tr>
                	<tr>            
                        <td width="50%"><label>(*) Fecha de fin </label></td>
                        <td>
							<input type="text" name="fechaFinal" maxlength="30">
							<input type="button" value="..." onclick="calen(2)">
						</td>
                    </tr>                                                            
                    <tr>
                    	<td colspan="2" align="right"><br /><input align="right" class="button" type="image" src="../../resources/design/save.gif"  onmouseover="changeOn(this);" onMouseOut="changeOff(this);"  onclick="changeClick(this);" name="btnLogin" /> </td>
					</tr>
				</table> 
				<input type="hidden" name="dateResult">
            </form>
               
				<br />
				<br />
 
            </div> <!-- /article -->

            <hr class="noscreen" />
            
        </div> <!-- /content -->

        <!-- Right column -->
        <div id="col" class="noprint">
            <div id="col-in">

                <!-- About Me -->
			<?php if (isset($_SESSION['login'])) { ?>
                <h3><span>Acerca de M&iacute;</span></h3>
                <div id="about-me">
                    <strong><?php echo $_SESSION['user_name'] ?></strong><br />
                    <?php echo $_SESSION['user_email'] ?><br />
                    Caracas, VEN<br /><br />
                    <a href="../controllers/logout.php">Cerrar Sesi&oacute;n</a></p>
                </div> <!-- /about-me -->
			 <?php } ?>

                <hr class="noscreen" />

                <!-- Category -->
                <h3 ><span>Opciones Generales</span></h3>

                <ul id="category">
                    <li><a href="opcion.php">Gestionar Opciones</a></li> 
                    <li><a href="factor.php">Gestionar Factores</a></li>
                </ul>

                <hr class="noscreen" />
                
            </div> <!-- /col-in -->
        </div> <!-- /col -->

    </div> <!-- /page-in -->
    </div> <!-- /page -->

    <!-- Footer -->
    <div id="footer">
        <div id="top" class="noprint"><p><span class="noscreen">Back on top</span> <a href="#header" title="Back on top ^">^<span></span></a></p></div>
        <hr class="noscreen" />
        
        <p id="createdby">creado por <a href="http://www.asodeco.org">PSC Asodeco</a> <!-- DON´T REMOVE, PLEASE! --></p>
        <p id="copyright">&copy; 2010 <a href="mailto:contacto@asodeco.org">Asodeco</a></p>
    </div> <!-- /footer -->

</div> <!-- /main -->

</body>
</html>
